//
//  BCChildViewController.m
//  GSBlockChain
//
//  Created by guoshikeji_a on 2018/11/12.
//  Copyright © 2018年 guoshikeji. All rights reserved.
//

#import "BCChildViewController.h"


@interface BCChildViewController ()

@end

@implementation BCChildViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.customNaviBar = [AKCustomNaviBar new];
    self.customNaviBar.backgroundColor = [UIColor whiteColor];
    [self.customNaviBar.leftButton setImage:[LOAD_IMAGE(@"navi_arrow_left") imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
    WEAK_SELF
    self.customNaviBar.didClickedNaviLeftButton = ^{
        [wself didClickedNaviLeftButton];
    };
    self.customNaviBar.didClickedNaviRightButton = ^{
        [wself didClickedNaviRightButton];
    };
    self.customNaviBar.didTappedNaviTitle = ^{
        [wself didClickedNaviTitle];
    };
    [self.view addSubview:self.customNaviBar];
    [self.customNaviBar mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view);
        make.width.equalTo(self.view);
        make.centerX.equalTo(self.view);
        make.height.mas_equalTo(Height_NavBar);
    }];
}

- (void)setTitle:(NSString *)title {
    [super setTitle:title];
    self.customNaviBar.titleLabel.text = title;
    [self.customNaviBar layoutSubviews];
}


- (void)didClickedNaviLeftButton {
    if (self.navigationController) {
        if (self.navigationController.viewControllers.count == 1) {
            [self.navigationController dismissViewControllerAnimated:YES completion:nil];
        }else {
            [self.navigationController popViewControllerAnimated:YES];
        }
    }else {
        [self dismissViewControllerAnimated:true completion:nil];
    }
}

- (void)didClickedNaviRightButton {
    
}

- (void)didClickedNaviTitle {
    
}

- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleDefault;
}


- (void)updateStatusBar {
    if ([self.customNaviBar.backgroundColor qmui_colorIsDark]) {
        self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
    }else {
        self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
    }
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    //
    [self.view bringSubviewToFront:self.customNaviBar];
    //
    [self updateStatusBar];
}



@end
